bin/git-histedit

Mon, 06 May 2019 12:36:55 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Mon, 06 May 2019 12:36:55 -0500
changeset 760
d439bf421f1b
parent 759
656f6f6f63cf
child 798
d690f45fd713
permissions
-rwxr-xr-x

fix

755
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1 #!/bin/sh
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2 set -eu
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
3
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
4 case ${1:-} in *help|-h)
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
5 exec perldoc -T $0;;
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
6 esac
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
7
759
656f6f6f63cf Fix escape
Meredith Howard <mhoward@roomag.org>
parents: 755
diff changeset
8 UPSTREAM="${1:-@{u}}"
755
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
9 BRANCH="${2:-$(git symbolic-ref --short -q HEAD || echo HEAD)}"
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
10
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
11 [ "$#" -ne 0 ] && shift
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
12 [ "$#" -ne 0 ] && shift
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
13
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
14 if git merge-base --is-ancestor "$UPSTREAM" "$BRANCH"; then
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
15 BASE=$(git rev-parse "$UPSTREAM")
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
16 else
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
17 BASE=$(git merge-base "$UPSTREAM" "$BRANCH")
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
18 fi
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
19
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
20 exec git rebase --interactive --autosquash "$BASE" "$BRANCH" "$@"
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
21
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
22 :<<=cut
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
23 =head1 NAME
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
24
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
25 git histedit
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
26
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
27 =head1 SYNOPSIS
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
28
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
29 $ git histedit
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
30
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
31 =head1 DESCRIPTION
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
32
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
33 C<histedit> lets you edit a branch using interactive rebase, but without
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
34 actually I<moving> the fork point of your branch, avoiding the complications of
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
35 fixing up your history and dealing with merge conflicts at the same time.
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
36
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
37 See also: C<hg histedit>
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
38
60ee3259bc01 add git-histedit
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
39 =cut

mercurial