git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCHv2 1/2] rebase -i: optimize the creation of the todo file
@ 2012-03-08 13:52 Dominique Quatravaux
  2012-03-08 13:52 ` [PATCHv2 2/2] rebase -i: new option --name-rev Dominique Quatravaux
  2012-03-09  5:00 ` [PATCHv2 1/2] rebase -i: optimize the creation of the todo file David Barr
  0 siblings, 2 replies; 7+ messages in thread
From: Dominique Quatravaux @ 2012-03-08 13:52 UTC (permalink / raw)
  To: git, Thomas Rast, Johannes Sixt; +Cc: Dominique Quatravaux

Instead of obtaining short SHA1's from "git rev-list" and hitting the repository
once more with "git rev-parse" for the full-size SHA1's, obtain both short and
long SHA1's from "git log" at once.
---
 git-rebase--interactive.sh |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 5812222..e408e94 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -774,17 +774,16 @@ else
 	revisions=$onto...$orig_head
 	shortrevisions=$shorthead
 fi
-git rev-list $merges_option --pretty=oneline --abbrev-commit \
+git rev-list $merges_option --format="%m%H %h %s" --abbrev-commit \
 	--abbrev=7 --reverse --left-right --topo-order \
 	$revisions | \
 	sed -n "s/^>//p" |
-while read -r shortsha1 rest
+while read -r sha1 shortsha1 rest
 do
 	if test t != "$preserve_merges"
 	then
 		printf '%s\n' "pick $shortsha1 $rest" >> "$todo"
 	else
-		sha1=$(git rev-parse $shortsha1)
 		if test -z "$rebase_root"
 		then
 			preserve=t
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCHv2 2/2] rebase -i: new option --name-rev
  2012-03-08 13:52 [PATCHv2 1/2] rebase -i: optimize the creation of the todo file Dominique Quatravaux
@ 2012-03-08 13:52 ` Dominique Quatravaux
  2012-03-09  5:00 ` [PATCHv2 1/2] rebase -i: optimize the creation of the todo file David Barr
  1 sibling, 0 replies; 7+ messages in thread
From: Dominique Quatravaux @ 2012-03-08 13:52 UTC (permalink / raw)
  To: git, Thomas Rast, Johannes Sixt; +Cc: Dominique Quatravaux

If set, the second column of the rebase todo contains named revisions (obtained
with git name-rev) instead of short SHA1s.
---
 Documentation/git-rebase.txt  |    7 +++++++
 git-rebase--interactive.sh    |   10 ++++++++--
 git-rebase.sh                 |   10 ++++++++++
 t/t3404-rebase-interactive.sh |   10 ++++++++++
 t/t3415-rebase-autosquash.sh  |   24 ++++++++++++++++++++++++
 5 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 504945c..da2aca7 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -365,6 +365,13 @@ If the '--autosquash' option is enabled by default using the
 configuration variable `rebase.autosquash`, this option can be
 used to override and disable this setting.
 
+--name-rev::
+	Instead of showing short SHA1 hashes in the todo list, show
+	human-readable revisions obtained with linkgit:git-name-rev[1].
++
+This option is only valid when the '--interactive' option is used. It can also
+be set through the `rebase.interactiveNameRev` configuration variable.
+
 --no-ff::
 	With --interactive, cherry-pick all rebased commits instead of
 	fast-forwarding over the unchanged ones.  This ensures that the
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index e408e94..c597b6b 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -780,9 +780,15 @@ git rev-list $merges_option --format="%m%H %h %s" --abbrev-commit \
 	sed -n "s/^>//p" |
 while read -r sha1 shortsha1 rest
 do
+	if test t = "$name_rev"
+	then
+		rev="$(git name-rev $sha1 | cut -d\  -f2)"
+	else
+		rev="$shortsha1"
+	fi
 	if test t != "$preserve_merges"
 	then
-		printf '%s\n' "pick $shortsha1 $rest" >> "$todo"
+		printf '%s\n' "pick $rev $rest" >> "$todo"
 	else
 		if test -z "$rebase_root"
 		then
@@ -800,7 +806,7 @@ do
 		if test f = "$preserve"
 		then
 			touch "$rewritten"/$sha1
-			printf '%s\n' "pick $shortsha1 $rest" >> "$todo"
+			printf '%s\n' "pick $rev $rest" >> "$todo"
 		fi
 	fi
 done
diff --git a/git-rebase.sh b/git-rebase.sh
index 69c1374..9330be3 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -43,6 +43,8 @@ s,strategy=!       use the given merge strategy
 no-ff!             cherry-pick all commits, even if unchanged
 m,merge!           use merging strategies to rebase
 i,interactive!     let the user edit the list of commits to rebase
+name-rev           show revisions by name in the list of commits
+no-name-rev        show revisions by short SHA1 in the list (default)
 f,force-rebase!    force rebase even if branch is up to date
 X,strategy-option=! pass the argument through to the merge strategy
 stat!              display a diffstat of what changed upstream
@@ -98,6 +100,8 @@ action=
 preserve_merges=
 autosquash=
 test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t
+name_rev=
+test "$(git config --bool rebase.interactivenamerev)" = "true" && name_rev=t
 
 read_basic_state () {
 	head_name=$(cat "$state_dir"/head-name) &&
@@ -287,6 +291,12 @@ do
 	-f|--no-ff)
 		force_rebase=t
 		;;
+	--name-rev)
+		name_rev=t
+		;;
+	--no-name-rev)
+		name_rev=
+		;;
 	--rerere-autoupdate|--no-rerere-autoupdate)
 		allow_rerere_autoupdate="$1"
 		;;
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index b981572..f3b4214 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -163,6 +163,16 @@ test_expect_success 'exchange two commits' '
 	test G = $(git cat-file commit HEAD | sed -ne \$p)
 '
 
+cat > expect-rebase-todo <<EOF
+pick branch1~1 H
+pick branch1 G
+EOF
+
+test_expect_success 'Symbolic revisions in --name-rev' '
+	FAKE_LINES="exec_cp_.git/rebase-merge/git-rebase-todo_rebase-todo 1 2" git rebase -i --name-rev HEAD~2 &&
+	test_cmp expect-rebase-todo rebase-todo
+'
+
 cat > expect << EOF
 diff --git a/file1 b/file1
 index f70f10e..fd79235 100644
diff --git a/t/t3415-rebase-autosquash.sh b/t/t3415-rebase-autosquash.sh
index b38be8e..3062e24 100755
--- a/t/t3415-rebase-autosquash.sh
+++ b/t/t3415-rebase-autosquash.sh
@@ -169,6 +169,30 @@ test_expect_success 'auto squash that matches longer sha1' '
 	test 1 = $(git cat-file commit HEAD^ | grep squash | wc -l)
 '
 
+test_expect_success 'auto fixup with --name-rev' '
+	git reset --hard base &&
+	echo 2 >file1 &&
+	git add -u &&
+	test_tick &&
+	git commit -m "changing file1" &&
+	echo 4 >file2 &&
+	git add -u &&
+	test_tick &&
+	git commit -m "changing file2" &&
+	echo 1 >file1 &&
+	git add -u &&
+	test_tick &&
+	git commit -m "fixup! changing file1" &&
+	git tag final-fixup-name-rev &&
+	test_tick &&
+	git rebase -i --autosquash --name-rev HEAD^^^ &&
+	git log --oneline base..HEAD >actual &&
+	test 2 = $(wc -l <actual) &&
+	git diff --exit-code final-fixup-name-rev &&
+	test 2 = "$(git cat-file blob HEAD^:file2)" &&
+	test 1 = $(git cat-file commit HEAD^ | grep changing | wc -l)
+'
+
 test_auto_commit_flags () {
 	git reset --hard base &&
 	echo 1 >file1 &&
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCHv2 1/2] rebase -i: optimize the creation of the todo file
  2012-03-08 13:52 [PATCHv2 1/2] rebase -i: optimize the creation of the todo file Dominique Quatravaux
  2012-03-08 13:52 ` [PATCHv2 2/2] rebase -i: new option --name-rev Dominique Quatravaux
@ 2012-03-09  5:00 ` David Barr
  2012-03-09  9:18   ` Dominique Quatravaux
  2012-03-09  9:47   ` Junio C Hamano
  1 sibling, 2 replies; 7+ messages in thread
From: David Barr @ 2012-03-09  5:00 UTC (permalink / raw)
  To: Dominique Quatravaux; +Cc: git, Thomas Rast, Johannes Sixt

On Fri, Mar 9, 2012 at 12:52 AM, Dominique Quatravaux <domq@google.com> wrote:
> Instead of obtaining short SHA1's from "git rev-list" and hitting the repository
> once more with "git rev-parse" for the full-size SHA1's, obtain both short and
> long SHA1's from "git log" at once.
> ---
>  git-rebase--interactive.sh |    5 ++---
>  1 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
> index 5812222..e408e94 100644
> --- a/git-rebase--interactive.sh
> +++ b/git-rebase--interactive.sh
> @@ -774,17 +774,16 @@ else
>        revisions=$onto...$orig_head
>        shortrevisions=$shorthead
>  fi
> -git rev-list $merges_option --pretty=oneline --abbrev-commit \
> +git rev-list $merges_option --format="%m%H %h %s" --abbrev-commit \
>        --abbrev=7 --reverse --left-right --topo-order \
>        $revisions | \
>        sed -n "s/^>//p" |
> -while read -r shortsha1 rest
> +while read -r sha1 shortsha1 rest
>  do
>        if test t != "$preserve_merges"
>        then
>                printf '%s\n' "pick $shortsha1 $rest" >> "$todo"
>        else
> -               sha1=$(git rev-parse $shortsha1)
>                if test -z "$rebase_root"
>                then
>                        preserve=t
> --
> 1.7.7.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Ack. Yay, less forking.

I do notice however that the output being fed to sed expands like so:

  commit >634a5f265ad729b91266de65272e2b5a35d05b1c
  >634a5f265ad729b91266de65272e2b5a35d05b1c 634a5f2 INSTALL: warn [...]
  commit >828ea97de486c1693d6e4f2c7347acb50235a85d
  >828ea97de486c1693d6e4f2c7347acb50235a85d 828ea97 Git 1.7.9

Maybe the format spec and sed command could use a little tuning.

--
David Barr

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCHv2 1/2] rebase -i: optimize the creation of the todo file
  2012-03-09  5:00 ` [PATCHv2 1/2] rebase -i: optimize the creation of the todo file David Barr
@ 2012-03-09  9:18   ` Dominique Quatravaux
  2012-03-09  9:21     ` Dominique Quatravaux
  2012-03-09  9:47   ` Junio C Hamano
  1 sibling, 1 reply; 7+ messages in thread
From: Dominique Quatravaux @ 2012-03-09  9:18 UTC (permalink / raw)
  To: David Barr; +Cc: git, Thomas Rast, Johannes Sixt

On Fri, Mar 9, 2012 at 6:00 AM, David Barr <davidbarr@google.com> wrote:
> I do notice however that the output being fed to sed expands like so:
>
>  commit >634a5f265ad729b91266de65272e2b5a35d05b1c
>  >634a5f265ad729b91266de65272e2b5a35d05b1c 634a5f2 INSTALL: warn [...]
>  commit >828ea97de486c1693d6e4f2c7347acb50235a85d
>  >828ea97de486c1693d6e4f2c7347acb50235a85d 828ea97 Git 1.7.9
>
> Maybe the format spec and sed command could use a little tuning.

Hmm, from rev-list.c it appears that "oneline" is the only format that has git
rev-list output one line per commit:

102 	if (revs->commit_format == CMIT_FMT_ONELINE)
103 		putchar(' ');
104 	else
105 		putchar('\n');

[...]

362 		if (revs.commit_format == CMIT_FMT_ONELINE)
363 			info.header_prefix = "";
364 		else
365 			info.header_prefix = "commit ";

I could fix that by using "git log" instead (hence the erroneous log message for
this patch, that I'll fix in the next attempt), but I don't know about the
implications of that (semantic or performance-wise). On the other hand, I can't
imagine how sed skipping every other "commit 12345abcdef" line could be a
noticeable performance drain. Advice welcome.

-- 
  Dominique Quatravaux
  +41 79 609 40 72

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCHv2 1/2] rebase -i: optimize the creation of the todo file
  2012-03-09  9:18   ` Dominique Quatravaux
@ 2012-03-09  9:21     ` Dominique Quatravaux
  0 siblings, 0 replies; 7+ messages in thread
From: Dominique Quatravaux @ 2012-03-09  9:21 UTC (permalink / raw)
  To: David Barr; +Cc: git, Thomas Rast, Johannes Sixt

On Fri, Mar 9, 2012 at 6:00 AM, David Barr <davidbarr@google.com> wrote:
>> I do notice however that the output being fed to sed expands like so:
>>
>>  commit >634a5f265ad729b91266de65272e2b5a35d05b1c
>>  >634a5f265ad729b91266de65272e2b5a35d05b1c 634a5f2 INSTALL: warn [...]
>>  commit >828ea97de486c1693d6e4f2c7347acb50235a85d
>>  >828ea97de486c1693d6e4f2c7347acb50235a85d 828ea97 Git 1.7.9
>>
>> Maybe the format spec and sed command could use a little tuning.

Never mind, I missed the "and sed command" part and now I get what you
have in mind. This is a bit beyond my sed skillz at the moment but
I'll get back to you :)

-- 
  Dominique Quatravaux
  +41 79 609 40 72

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCHv2 1/2] rebase -i: optimize the creation of the todo file
  2012-03-09  5:00 ` [PATCHv2 1/2] rebase -i: optimize the creation of the todo file David Barr
  2012-03-09  9:18   ` Dominique Quatravaux
@ 2012-03-09  9:47   ` Junio C Hamano
  2012-03-09  9:52     ` Dominique Quatravaux
  1 sibling, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2012-03-09  9:47 UTC (permalink / raw)
  To: David Barr; +Cc: Dominique Quatravaux, git, Thomas Rast, Johannes Sixt

David Barr <davidbarr@google.com> writes:

> I do notice however that the output being fed to sed expands like so:
>
>   commit >634a5f265ad729b91266de65272e2b5a35d05b1c
>   >634a5f265ad729b91266de65272e2b5a35d05b1c 634a5f2 INSTALL: warn [...]
>   commit >828ea97de486c1693d6e4f2c7347acb50235a85d
>   >828ea97de486c1693d6e4f2c7347acb50235a85d 828ea97 Git 1.7.9
>
> Maybe the format spec and sed command could use a little tuning.

Why would that be a problem, though?  The sed script picks only
lines that begin with '>' and discards the traditional diff-tree
style per commit header, no?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCHv2 1/2] rebase -i: optimize the creation of the todo file
  2012-03-09  9:47   ` Junio C Hamano
@ 2012-03-09  9:52     ` Dominique Quatravaux
  0 siblings, 0 replies; 7+ messages in thread
From: Dominique Quatravaux @ 2012-03-09  9:52 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: David Barr, git, Thomas Rast, Johannes Sixt

On Fri, Mar 9, 2012 at 10:47 AM, Junio C Hamano <gitster@pobox.com> wrote:
> David Barr <davidbarr@google.com> writes:
>
>> I do notice however that the output being fed to sed expands like so:
>>
>>   commit >634a5f265ad729b91266de65272e2b5a35d05b1c
>>   >634a5f265ad729b91266de65272e2b5a35d05b1c 634a5f2 INSTALL: warn [...]
>>   commit >828ea97de486c1693d6e4f2c7347acb50235a85d
>>   >828ea97de486c1693d6e4f2c7347acb50235a85d 828ea97 Git 1.7.9
>>
>> Maybe the format spec and sed command could use a little tuning.
>
> Why would that be a problem, though?  The sed script picks only
> lines that begin with '>' and discards the traditional diff-tree
> style per commit header, no?

I assume that David wants to have

  commit >634a5f265ad729b91266de65272e2b5a35d05b1c
  634a5f2 INSTALL: warn [...]

and chew on that with sed.

-- 
  Dominique Quatravaux
  +41 79 609 40 72

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-03-09  9:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-08 13:52 [PATCHv2 1/2] rebase -i: optimize the creation of the todo file Dominique Quatravaux
2012-03-08 13:52 ` [PATCHv2 2/2] rebase -i: new option --name-rev Dominique Quatravaux
2012-03-09  5:00 ` [PATCHv2 1/2] rebase -i: optimize the creation of the todo file David Barr
2012-03-09  9:18   ` Dominique Quatravaux
2012-03-09  9:21     ` Dominique Quatravaux
2012-03-09  9:47   ` Junio C Hamano
2012-03-09  9:52     ` Dominique Quatravaux

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).