Skip to content

Commit 8d30e3c

Browse files
committed
Use uni2ascii if available to create more readable file names when commits messages have non-ascii characters.
1 parent 0a67768 commit 8d30e3c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ Patches can be readily edited, shared with others and applied in a new order.
4343

4444
Patches are created using ```git format-patch```, and can be applied using ```git am```, in addition to ```git-uncommit```
4545

46+
Patches are given readable file names extracted from your commit messages.
47+
4648
## Comparison with related Git commands
4749

4850
```git stash``` can sometimes be used for similar purposes as ```git-uncommit```, the differences are:
@@ -61,6 +63,8 @@ Patches are created using ```git format-patch```, and can be applied using ```gi
6163

6264
In a Unix or Linux system, you can quickly install ```git-recommit``` and ```git-uncommit``` by copying the files to ```/usr/local/bin```.
6365

66+
Installing ```uni2ascii``` will help ```git-uncommit``` create better filenames for patches, when your commit messages have non-ascii characters.
67+
6468
## Author and licensing terms
6569

6670
````

git-uncommit

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,16 @@ die() {
2929
exit 1
3030
}
3131

32+
toascii() {
33+
if which uni2ascii >/dev/null 2>&1; then
34+
uni2ascii -qeB
35+
else
36+
cat
37+
fi
38+
}
39+
3240
namecommit() {
33-
(git show "$1"|git patch-id|head --bytes=7; git show "$1"|head -n5|tail -n1)|sed -E "; s/[^a-zA-Z0-9]+/ /g; s/^ //; s/ $//; s/ /-/g"|head --bytes=40|tr A-Z a-z|sed "s/-$//"
41+
(git show "$1"|git patch-id|head --bytes=7; git show "$1"|head -n5|tail -n1)|toascii|sed -E "; s/[^a-zA-Z0-9]+/ /g; s/^ //; s/ $//; s/ /-/g"|head --bytes=40|tr A-Z a-z|sed "s/-$//"
3442
}
3543

3644
branchname() {

0 commit comments

Comments
 (0)