Skip to main content

git/gp

1#!/usr/bin/env bash
2# Pull any changes from the remote Git server.
3#
4# This writes a list of files that will be changed to `.git/names_diff.txt`,
5# which can be used by upstream scripts to customise their behaviour.
7set -o errexit
8set -o nounset
10_ensure_ssh_key_loaded
12ROOT="$(git rev-parse --show-toplevel)"
13HEAD="$(git rev-parse --abbrev-ref HEAD)"
15# This avoids any clashes with other programs called "gp", e.g. at one
16# point I had gitpython in my PATH
17$(dirname "$0")/gf
19echo ""
21# Log a list of files which will be changed to .git/names_diff.txt
22git diff --name-status "$HEAD" "origin/$HEAD" > "$ROOT/.git/names_diff.txt" 2>/dev/null
24if [[ "${1:-}" == "--rebase" ]]
25then
26 print_info "-> git rebase origin/$HEAD"
27 git rebase "origin/$HEAD"
28else
29 print_info "-> git merge origin/$HEAD"
30 git merge "origin/$HEAD"
31fi