Devuan fork of gpsd
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

53 lines
1.5 KiB

  1. #!/bin/sh
  2. # Give this a commit-ID specification. It will edit the associated comment.
  3. # Usual caveats apply; the edited one and all commits after will change IDs,
  4. # and pushing them to a repo with the old commits will wreak havoc.
  5. # Note also that this cavalierly overwrites refs/original.
  6. #
  7. # This script by Eric S. Raymond, March 2010, all rites perverted. It's based
  8. # on an idea by thiago from #git, but debugged and with a safety check.
  9. # It contains porcelain and porcelain byproducts.
  10. topdir=`git rev-parse --show-cdup`
  11. test -n "$topdir" && cd "$topdir"
  12. my_commit=`git rev-parse $1` || exit $?
  13. # Run a safety check before edits that could hose remotes.
  14. if test -n "`git branch -r --contains $mycommit`"
  15. then
  16. echo -n "Commit has been pushed. Really edit? "
  17. read yn
  18. if test "$yn" != 'y'
  19. then
  20. exit 0
  21. fi
  22. fi
  23. my_file=COMMIT_EDITMSG
  24. test -d .git && myfile=.git/COMMIT_EDITMSG
  25. # This effort to invoke the user's normal editor fails.
  26. # the problem is that anything the editor writes to stdout on the
  27. # controlling terminal becomes part of the commit message. So
  28. # the editor needs to actually run inside another window.
  29. #test -z "$GIT_EDITOR" && GIT_EDITOR=$EDITOR
  30. #test -z "$GIT_EDITOR" && GIT_EDITOR=vi
  31. #my_editor=$GIT_EDITOR
  32. # xterm -e vi should also work.
  33. my_editor=emacsclient
  34. export my_file my_commit my_editor
  35. exec git filter-branch -f --tag-name-filter cat --msg-filter '
  36. if test "$GIT_COMMIT" = "$my_commit"; then
  37. cat > $my_file;
  38. $my_editor $my_file >/dev/null;
  39. cat $my_file
  40. else
  41. cat
  42. fi' "$1~.."
  43. # End