Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 889a761

Browse files
committed
Add git-pick-commit
1 parent c51c417 commit 889a761

File tree

4 files changed

+45
-4
lines changed

4 files changed

+45
-4
lines changed

‎Makefile‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,24 @@ BINS = \
1010
git-ptt \
1111
git-set-message \
1212
git-synth \
13-
git-pick \
13+
git-pick-ref \
14+
git-pick-commit \
1415
git-resume
1516

1617
GENERATED = \
1718
git-mark \
1819
git-ptt \
1920
git-set-message \
20-
git-pick
21+
git-pick-ref \
22+
git-pick-commit
2123

2224
all: $(BINS)
2325

24-
git-pick: common.sh git-pick.in.sh
26+
git-pick-ref: common.sh git-pick-ref.in.sh
27+
cat $^ > $@
28+
chmod 755 $@
29+
30+
git-pick-commit: common.sh git-pick-commit.in.sh
2531
cat $^ > $@
2632
chmod 755 $@
2733

‎git-pick-commit.in.sh‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
OPTS_SPEC="\
2+
${0##*/} [<options>] [<pattern>]
3+
4+
Select a commit using fzf.
5+
--
6+
h,help Show the help
7+
8+
c,checkout Pass selection to 'git checkout'
9+
"
10+
11+
checkout=0
12+
fzf_opts=()
13+
14+
eval "$(git rev-parse --parseopt -- "$@" <<<$OPTS_SPEC || echo exit $?)"
15+
16+
while (( $# > 0 )); do
17+
case 1ドル in
18+
(-c) checkout=1
19+
shift
20+
;;
21+
22+
(--) shift
23+
break
24+
;;
25+
26+
(-*) DIE "unknown option: 1ドル"
27+
;;
28+
esac
29+
done
30+
shift $(( OPTIND - 1 ))
31+
32+
33+
git log --format='%h %s' --abbrev=10 |
34+
fzf "${fzf_opts[@]}" --preview='git show -q {1}' |
35+
awk '{print 1ドル}'
File renamed without changes.

‎git-set-message.in.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ done
7575

7676
if [[ -z ${message_file+UNSET} ]]; then
7777
message_file="$(git rev-parse --git-dir)/COMMIT_EDITMSG"
78-
git cat-file -p $oldref | sed '1,/^$/d' > $message_file
78+
git cat-file -p $oldref | sed '1,/^$/d' | tr -d '\r'> $message_file
7979
${VISUAL:-${EDITOR:-vi}} $message_file || DIE "failed to edit message"
8080
fi
8181

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /