public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] contrib: git gcc-descr defaulting to print hash
@ 2021-10-08 11:01 Martin Liška
  2021-10-08 11:12 ` Jakub Jelinek
  0 siblings, 1 reply; 15+ messages in thread
From: Martin Liška @ 2021-10-08 11:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: Martin Jambor, Jakub Jelinek, Jonathan Wakely

Hello.

I'm sending a patch originally written by Martin Jambor.
The patch changes the behavior in the following way:

$ git gcc-descr HEAD~

r12-4245-gdb3d7270b42fe2

$ git gcc-descr --short HEAD~

r12-4245

$ git gcc-undescr r12-4245-gdb3d7270b42fe2

db3d7270b42fe27fb05664c4fdf524ab7ad13a75

while right now, one gets:
$ git gcc-descr

r12-4090

$ git gcc-undescr r12-4245-gdb3d7270b42fe2
Invalid id r12-4245-gdb3d7270b42fe2

Thoughts?
Martin

contrib/ChangeLog:

	* gcc-git-customization.sh: Remove --full option and add --short
	one. By default, gcc-descr prints 14 characters of hash.
	gcc-undescr supports r$number-$number-$hash format.
---
  contrib/gcc-git-customization.sh | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/gcc-git-customization.sh b/contrib/gcc-git-customization.sh
index aca61b781ff..b63c4c80935 100755
--- a/contrib/gcc-git-customization.sh
+++ b/contrib/gcc-git-customization.sh
@@ -22,8 +22,8 @@ git config alias.svn-rev '!f() { rev=$1; shift; git log --all --grep="^From-SVN:
  
  # Add git commands to convert git commit to monotonically increasing revision number
  # and vice versa
-git config alias.gcc-descr \!"f() { if test \${1:-no} = --full; then c=\${2:-master}; r=\$(git describe --all --abbrev=40 --match 'basepoints/gcc-[0-9]*' \$c | sed -n 's,^\\(tags/\\)\\?basepoints/gcc-,r,p'); expr match \${r:-no} '^r[0-9]\\+\$' >/dev/null && r=\${r}-0-g\$(git rev-parse \${2:-master}); else c=\${1:-master}; r=\$(git describe --all --match 'basepoints/gcc-[0-9]*' \$c | sed -n 's,^\\(tags/\\)\\?basepoints/gcc-\\([0-9]\\+\\)-\\([0-9]\\+\\)-g[0-9a-f]*\$,r\\2-\\3,p;s,^\\(tags/\\)\\?basepoints/gcc-\\([0-9]\\+\\)\$,r\\2-0,p'); fi; if test -n \$r; then o=\$(git config --get gcc-config.upstream); rr=\$(echo \$r | sed -n 's,^r\\([0-9]\\+\\)-[0-9]\\+\\(-g[0-9a-f]\\+\\)\\?\$,\\1,p'); if git rev-parse --verify --quiet \${o:-origin}/releases/gcc-\$rr >/dev/null; then m=releases/gcc-\$rr; else m=master; fi; git merge-base --is-ancestor \$c \${o:-origin}/\$m && \echo \${r}; fi; }; f"
-git config alias.gcc-undescr \!"f() { o=\$(git config --get gcc-config.upstream); r=\$(echo \$1 | sed -n 's,^r\\([0-9]\\+\\)-[0-9]\\+\$,\\1,p'); n=\$(echo \$1 | sed -n 's,^r[0-9]\\+-\\([0-9]\\+\\)\$,\\1,p'); test -z \$r && echo Invalid id \$1 && exit 1; h=\$(git rev-parse --verify --quiet \${o:-origin}/releases/gcc-\$r); test -z \$h && h=\$(git rev-parse --verify --quiet \${o:-origin}/master); p=\$(git describe --all --match 'basepoints/gcc-'\$r \$h | sed -n 's,^\\(tags/\\)\\?basepoints/gcc-[0-9]\\+-\\([0-9]\\+\\)-g[0-9a-f]*\$,\\2,p;s,^\\(tags/\\)\\?basepoints/gcc-[0-9]\\+\$,0,p'); git rev-parse --verify \$h~\$(expr \$p - \$n); }; f"
+git config alias.gcc-descr \!"f() { if test \${1:-no} = --short; then c=\${2:-master}; r=\$(git describe --all --match 'basepoints/gcc-[0-9]*' \$c | sed -n 's,^\\(tags/\\)\\?basepoints/gcc-\\([0-9]\\+\\)-\\([0-9]\\+\\)-g[0-9a-f]*\$,r\\2-\\3,p;s,^\\(tags/\\)\\?basepoints/gcc-\\([0-9]\\+\\)\$,r\\2-0,p'); else c=\${1:-master}; r=\$(git describe --all --abbrev=14 --match 'basepoints/gcc-[0-9]*' \$c | sed -n 's,^\\(tags/\\)\\?basepoints/gcc-,r,p'); expr match \${r:-no} '^r[0-9]\\+\$' >/dev/null && r=\${r}-0-g\$(git rev-parse \${2:-master}); fi; if test -n \$r; then o=\$(git config --get gcc-config.upstream); rr=\$(echo \$r | sed -n 's,^r\\([0-9]\\+\\)-[0-9]\\+\\(-g[0-9a-f]\\+\\)\\?\$,\\1,p'); if git rev-parse --verify --quiet \${o:-origin}/releases/gcc-\$rr >/dev/null; then m=releases/gcc-\$rr; else m=master; fi; git merge-base --is-ancestor \$c \${o:-origin}/\$m && \\echo \${r}; fi; }; f"
+git config alias.gcc-undescr \!"f() { o=\$(git config --get gcc-config.upstream); r=\$(echo \$1 | sed 's/\\([^-]*-[^-]*\\)-.*/\\1/' | sed -n 's,^r\\([0-9]\\+\\)-[0-9]\\+\$,\\1,p'); n=\$(echo \$1 | sed 's/\\([^-]*-[^-]*\\)-.*/\\1/' | sed -n 's,^r[0-9]\\+-\\([0-9]\\+\\)\$,\\1,p'); test -z \$r && echo Invalid id \$1 && exit 1; h=\$(git rev-parse --verify --quiet \${o:-origin}/releases/gcc-\$r); test -z \$h && h=\$(git rev-parse --verify --quiet \${o:-origin}/master); p=\$(git describe --all --match 'basepoints/gcc-'\$r \$h | sed -n 's,^\\(tags/\\)\\?basepoints/gcc-[0-9]\\+-\\([0-9]\\+\\)-g[0-9a-f]*\$,\\2,p;s,^\\(tags/\\)\\?basepoints/gcc-[0-9]\\+\$,0,p'); git rev-parse --verify \$h~\$(expr \$p - \$n); }; f"
  
  git config alias.gcc-verify '!f() { "`git rev-parse --show-toplevel`/contrib/gcc-changelog/git_check_commit.py" $@; } ; f'
  git config alias.gcc-backport '!f() { "`git rev-parse --show-toplevel`/contrib/git-backport.py" $@; } ; f'
-- 
2.33.0


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

end of thread, other threads:[~2022-01-27 17:44 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-08 11:01 [PATCH] contrib: git gcc-descr defaulting to print hash Martin Liška
2021-10-08 11:12 ` Jakub Jelinek
2021-10-11 12:32   ` [RFC] Port git gcc-descr to Python Martin Liška
2021-10-12  8:59     ` Martin Liška
2021-10-14  9:06       ` Tobias Burnus
2021-10-14  9:19         ` Jakub Jelinek
2021-10-18  9:01       ` Martin Liška
2022-01-19 11:01         ` Martin Liška
2022-01-19 12:49           ` Martin Jambor
2022-01-19 13:17             ` Martin Liška
2022-01-19 16:54               ` Eric Gallager
2022-01-27 15:06             ` [PATCH] contrib: Put gcc-descr and gcc-undescr to file Martin Liška
2022-01-27 15:35               ` Jakub Jelinek
2022-01-27 17:44                 ` Martin Liška
2022-01-27 15:51               ` Jonathan Wakely

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).