Skip to contentSkip to conversation

Handles slashes in branch names

PATCH In review Eric Lesh 2 participants 4 messages Jun 15, 2016

lore
Share & tools
lore

Eric Lesh

author
#0 lore raw

PATCH 1/1 Handles slashes in branch names

When a branch name has a slash and autotagging is enabled, guilt barfs when updating the stack tags. Escape the branch name in the tags to allow this to work.

Also allow guilt to create the patches directory for these branches.

---
 guilt      |   15 +++++++++------
 guilt-init |    2 +-
 2 files changed, 10 insertions(+), 7 deletions(-)
guilt +9 -6
index 214def4..9e4789a 100755
@@ -334,20 +334,23 @@ update_stack_tags()
 		return 0
 	fi
 
+        # handle branches with slashes
+        newbranch=`echo $branch | sed -e 's,\/,-,'`
+
 	if [ `wc -l < $applied` -gt 0 ]; then
 		# there are patches applied, therefore we must get the top,
 		# bottom and base hashes, and update the tags
 
-		git-rev-parse HEAD > "$GIT_DIR/refs/tags/${branch}_top"
-		head -1 < $applied | cut -d: -f1 > "$GIT_DIR/refs/tags/${branch}_bottom"
-		git-rev-parse $(head -1 < $applied | cut -d: -f1)^ > "$GIT_DIR/refs/tags/${branch}_base"
+		git-rev-parse HEAD > "$GIT_DIR/refs/tags/${newbranch}_top"
+		head -1 < $applied | cut -d: -f1 > "$GIT_DIR/refs/tags/${newbranch}_bottom"
+		git-rev-parse $(head -1 < $applied | cut -d: -f1)^ > "$GIT_DIR/refs/tags/${newbranch}_base"
 	else
 		# there are no patches applied, therefore we must remove the
 		# tags to old top, bottom, and base
 
-		rm -f "$GIT_DIR/refs/tags/${branch}_top"
-		rm -f "$GIT_DIR/refs/tags/${branch}_bottom"
-		rm -f "$GIT_DIR/refs/tags/${branch}_base"
+		rm -f "$GIT_DIR/refs/tags/${newbranch}_top"
+		rm -f "$GIT_DIR/refs/tags/${newbranch}_bottom"
+		rm -f "$GIT_DIR/refs/tags/${newbranch}_base"
 	fi
 }
 
guilt-init +1 -1
index ffe2434..9136f89 100755
@@ -24,7 +24,7 @@ if [ -d "$GUILT_DIR/$branch" ]; then
 fi
 
 [ ! -d "$GUILT_DIR" ] && mkdir $GUILT_DIR
-mkdir $GUILT_DIR/$branch
+mkdir -p $GUILT_DIR/$branch
 touch $GUILT_DIR/$branch/series
 touch $GUILT_DIR/$branch/status
 
Signature · 1 line
1.5.2
#1 lore raw
Quoted 3 lines · Eric Lesh

When a branch name has a slash and autotagging is enabled, guilt barfs when updating the stack tags. Escape the branch name in the tags to allow this to work.

...

guilt update_stack_tags() · line 346

Quoted 6 lines
guilt +3 -3
-		git-rev-parse HEAD > "$GIT_DIR/refs/tags/${branch}_top"
-		head -1 < $applied | cut -d: -f1 > "$GIT_DIR/refs/tags/${branch}_bottom"
-		git-rev-parse $(head -1 < $applied | cut -d: -f1)^ > "$GIT_DIR/refs/tags/${branch}_base"
+		git-rev-parse HEAD > "$GIT_DIR/refs/tags/${newbranch}_top"
+		head -1 < $applied | cut -d: -f1 > "$GIT_DIR/refs/tags/${newbranch}_bottom"
+		git-rev-parse $(head -1 < $applied | cut -d: -f1)^ > "$GIT_DIR/refs/tags/${newbranch}_base"

Why mangle the branch name when we can do:

mkdir -p basename $GIT_DIR/refs/tags/${branch}_top git-rev-parse ....

Sure, it is ugly, but it preserves the branch name. Am I missing something?

Josef 'Jeff' Sipek.

Signature · 1 line
A computer without Microsoft is like chocolate cake without mustard.
author
#2 lore raw

PATCH 1/1 Handles slashes in branch names

When a branch name has a slash and autotagging is enabled, guilt barfs when updating the stack tags. Make these branch names work.

Also allow guilt to create the patches directory for these branches.

---

Quoted 8 lines · Josef Sipek

Why mangle the branch name when we can do:

mkdir -p basename $GIT_DIR/refs/tags/${branch}_top git-rev-parse ....

Sure, it is ugly, but it preserves the branch name. Am I missing something?

Yours is a lot less ugly than mine was.

 guilt      |    1 +
 guilt-init |    2 +-
 2 files changed, 2 insertions(+), 1 deletions(-)
guilt +1 -0
index 214def4..c913bd6 100755
@@ -338,6 +338,7 @@ update_stack_tags()
 		# there are patches applied, therefore we must get the top,
 		# bottom and base hashes, and update the tags
 
+		mkdir -p `dirname $GIT_DIR/refs/tags/${branch}_top`
 		git-rev-parse HEAD > "$GIT_DIR/refs/tags/${branch}_top"
 		head -1 < $applied | cut -d: -f1 > "$GIT_DIR/refs/tags/${branch}_bottom"
 		git-rev-parse $(head -1 < $applied | cut -d: -f1)^ > "$GIT_DIR/refs/tags/${branch}_base"
guilt-init +1 -1
index ffe2434..9136f89 100755
@@ -24,7 +24,7 @@ if [ -d "$GUILT_DIR/$branch" ]; then
 fi
 
 [ ! -d "$GUILT_DIR" ] && mkdir $GUILT_DIR
-mkdir $GUILT_DIR/$branch
+mkdir -p $GUILT_DIR/$branch
 touch $GUILT_DIR/$branch/series
 touch $GUILT_DIR/$branch/status
 
Signature · 1 line
1.5.2
Applied
#3 lore raw
Quoted 6 lines · Eric Lesh

When a branch name has a slash and autotagging is enabled, guilt barfs when updating the stack tags. Make these branch names work.

Also allow guilt to create the patches directory for these branches.

Applied. I just added quotes around the mkdir -p in guilt in case someone likes to have whitespace in their branch names.

Thanks,

Josef 'Jeff' Sipek.

Signature · 4 lines
Real Programmers consider "what you see is what you get" to be just as bad a
concept in Text Editors as it is in women. No, the Real Programmer wants a
"you asked for it, you got it" text editor -- complicated, cryptic,
powerful, unforgiving, dangerous.