andsens / homeshick

git dotfiles synchronizer written in bash
MIT License
2.11k stars 145 forks source link

tag message prompt when pulling #225

Closed andsens closed 2 months ago

andsens commented 2 months ago

Users get prompted for a tag message when pulling. The likely culprit is this change: https://github.com/andsens/homeshick/pull/219/files#diff-e8b00e2a7b69de8008a16e90ba6b4fcfa1991b20682eb96e2121373f6e8a31fbR22

We just need to make sure the tag call is interactive.

@yut23

yut23 commented 2 months ago

That command should create a lightweight tag (as opposed to an annotated tag), which shouldn't ask for a message. Can you try with export GIT_TRACE=1 GIT_TRACE_REFS=1 beforehand, to see exactly what git is trying to do?

andsens commented 2 months ago

@thetrompf can you reproduce and check?

andsens commented 2 months ago

There we go, ran into it myself now image

GIT_TRACE=1 GIT_TRACE_REFS=1 homeshick pull orbit-dotfiles
13:05:15.911978 git.c:439               trace: built-in: git version
         pull orbit-dotfiles13:05:15.922301 git.c:439               trace: built-in: git tag __homeshick-before-pull__
13:05:15.922638 refs/debug.c:27         ref_store for .git
13:05:15.922651 refs/debug.c:255        read_raw_ref: HEAD: 0000000000000000000000000000000000000000 (=> refs/heads/master) type 1: 0
13:05:15.922662 refs/debug.c:255        read_raw_ref: refs/heads/master: 2c228539fae87da9936b0ad494a8392b87d1cf97 (=> refs/heads/master) type 0: 0
13:05:15.922673 refs/debug.c:258        read_raw_ref: refs/HEAD: -1 (errno 2)
13:05:15.922679 refs/debug.c:258        read_raw_ref: refs/tags/HEAD: -1 (errno 2)
13:05:15.922684 refs/debug.c:258        read_raw_ref: refs/heads/HEAD: -1 (errno 2)
13:05:15.922689 refs/debug.c:258        read_raw_ref: refs/remotes/HEAD: -1 (errno 2)
13:05:15.922694 refs/debug.c:258        read_raw_ref: refs/remotes/HEAD/HEAD: -1 (errno 2)
13:05:15.922699 refs/debug.c:258        read_raw_ref: refs/tags/__homeshick-before-pull__: -1 (errno 2)
13:05:15.922769 refs/debug.c:238        ref_iterator_begin: "refs/replace/" (0x1)
13:05:15.922774 refs/debug.c:191        iterator_advance: (-1)
hint: Waiting for your editor to close the file... 13:05:15.923051 run-command.c:655       trace: run_command: micro /home/aim/.homesick/repos/orbit-dotfiles/.git/TAG_EDITMSG
fatal: no tag message?
         pull orbit-dotfiles
andsens commented 2 months ago

Oh! image

combined with:

image

in the git config will cause git to require a message.

andsens commented 2 months ago

Fixed in ea9511acfcb3df887da5f64ed8e03e787ae21879

jovial-snyder commented 2 months ago

FYI I had this problem (even after doing a git pull):

~ hs refresh
        fresh homeshick-dotfiles
        fresh homeshick
~ hs check
   up to date homeshick-dotfiles
   up to date homeshick
~ hs pull
         pull homeshick-dotfiles
        error Pull marker tag (__homeshick-before-pull__) already exists in /home/marc/.homesick/repos/homeshick-dotfiles. Please resolve this before pulling.
         pull homeshick
        error Pull marker tag (__homeshick-before-pull__) already exists in /home/marc/.homesick/repos/homeshick. Please resolve this before pulling.

And I solved this by manually deleting the tag:

git tag -d __homeshick-before-pull__
git push origin :refs/tags/__homeshick-before-pull__ 
andsens commented 2 months ago

Oh boy. Yeah if people accidentally push that tag because of an incomplete pull there's quite a bit of trouble ahead. This method has to be rethought. Ideally we should just memo the current HEAD sha before pulling and somehow look it up later, this way we don't mess with the repo at all.

yut23 commented 2 months ago

I've got a different approach here that I wrote before I switched to using tags: https://github.com/andsens/homeshick/compare/master...yut23:homeshick:fix-pull-symlinking-old Before pulling each castle, it stores the current HEAD sha and only adds each castle to the list to symlink if the HEAD changed afterward. That way we can just do git diff @{1} HEAD to get the new files.

In retrospect, it's a lot cleaner than tags after all the error handling was added.

andsens commented 1 month ago

FYI. This is on master now.