[PATCH v2] git-rebase--interactive.sh: add config option for custom instruction format

DORMANTno replies

4 messages, 2 authors, 2016-06-15 · open the first message on its own page

[PATCH v2] git-rebase--interactive.sh: add config option for custom instruction format

From: Michael Rappazzo <hidden>
Date: 2016-06-15 23:05:13

Difference between v1 and v2 of this patch:

    - Fixed indentation from spaces to match the existing style
    - Changed the prepended sha1 from short (%h) to long (%H)
    - Used bash variable default when the config option is not present

Michael Rappazzo (1):
  git-rebase--interactive.sh: add config option for custom instruction
    format

 git-rebase--interactive.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

-- 
2.4.2

[PATCH v2] git-rebase--interactive.sh: add config option for custom instruction format

From: Michael Rappazzo <hidden>
Date: 2016-06-15 23:05:13

A config option 'rebase.instructionFormat' can override the
default 'oneline' format of the rebase instruction list.

Since the list is parsed using the left, right or boundary mark plus
the sha1, they are prepended to the instruction format.

Signed-off-by: Michael Rappazzo <redacted>
---
 git-rebase--interactive.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index dc3133f..b92375e 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -977,7 +977,9 @@ else
 	revisions=$onto...$orig_head
 	shortrevisions=$shorthead
 fi
-git rev-list $merges_option --pretty=oneline --reverse --left-right --topo-order \
+format=$(git config --get rebase.instructionFormat)
+# the 'rev-list .. | sed' requires %m to parse; the instruction requires %H to parse
+git rev-list $merges_option --format="%m%H ${format-%s}" --reverse --left-right --topo-order \
 	$revisions ${restrict_revision+^$restrict_revision} | \
 	sed -n "s/^>//p" |
 while read -r sha1 rest
-- 
2.4.2

Re: [PATCH v2] git-rebase--interactive.sh: add config option for custom instruction format

From: Johannes Schindelin <hidden>
Date: 2016-06-15 23:05:13

Hi,

On 2015-06-08 23:00, Michael Rappazzo wrote:
quoted hunk
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index dc3133f..b92375e 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -977,7 +977,9 @@ else
 	revisions=$onto...$orig_head
 	shortrevisions=$shorthead
 fi
-git rev-list $merges_option --pretty=oneline --reverse --left-right
--topo-order \
+format=$(git config --get rebase.instructionFormat)
+# the 'rev-list .. | sed' requires %m to parse; the instruction
requires %H to parse
+git rev-list $merges_option --format="%m%H ${format-%s}" --reverse
--left-right --topo-order \
These two lines are too long (longer than 80 columns)...

Besides, are you sure you don't want to substitute an empty 'rebase.instructionFormat' by '%s'? I would have expected to read `${format:-%s}` (note the colon), but then, this was Junio's suggestion... Junio, what do you think, should we not rather substitute empty values by `%s` as if the config setting was unset?
 	$revisions ${restrict_revision+^$restrict_revision} | \
 	sed -n "s/^>//p" |
 while read -r sha1 rest
Ciao,
Johannes

Re: [PATCH v2] git-rebase--interactive.sh: add config option for custom instruction format

From: Mike Rappazzo <hidden>
Date: 2016-06-15 23:05:13

I see your point, and I'll explore that avenue.

Personally, I like the idea that one could also use the short hash if
the custom instruction started with "%h ", but I see the value in
leaving the variable blank.

After running the tests with a custom format enabled, I did find that
autosquash doesn't work, so I am working to correct that.

On Tue, Jun 9, 2015 at 5:36 AM, Johannes Schindelin
[off-list ref] wrote:
Hi,

On 2015-06-08 23:00, Michael Rappazzo wrote:
quoted
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index dc3133f..b92375e 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -977,7 +977,9 @@ else
      revisions=$onto...$orig_head
      shortrevisions=$shorthead
 fi
-git rev-list $merges_option --pretty=oneline --reverse --left-right
--topo-order \
+format=$(git config --get rebase.instructionFormat)
+# the 'rev-list .. | sed' requires %m to parse; the instruction
requires %H to parse
+git rev-list $merges_option --format="%m%H ${format-%s}" --reverse
--left-right --topo-order \
These two lines are too long (longer than 80 columns)...

Besides, are you sure you don't want to substitute an empty 'rebase.instructionFormat' by '%s'? I would have expected to read `${format:-%s}` (note the colon), but then, this was Junio's suggestion... Junio, what do you think, should we not rather substitute empty values by `%s` as if the config setting was unset?
quoted
      $revisions ${restrict_revision+^$restrict_revision} | \
      sed -n "s/^>//p" |
 while read -r sha1 rest
Ciao,
Johannes
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help