Skip to content

Commit

Permalink
Exclude the no-op rebase case from the adjusted reflog
Browse files Browse the repository at this point in the history
  • Loading branch information
PawelLipski committed Dec 24, 2018
1 parent 6370ac8 commit d87187c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ git machete --version

## Please `cp -r .git .git.bak` or there's no hope!

Please back-up your `.git` folder at its current state for the issue to be reproducible in the future!
Please back-up your `.git` folder at its current state for the issue to be reproducible in the future!
Since `git machete` heavily relies on branch reflogs (`.git/logs/refs/`) that change as state of the repository changes, get expired due to `git gc` etc., not doing this almost guarantees we won't be able to reproduce the issue and determine whether it was fixed or not.

## Additional diagnostics info
Expand Down
10 changes: 7 additions & 3 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release notes

## New in git-machete 2.8.5

- fixed: fork point of a branch could be determined incorrectly when a no-op rebase has been performed on some other branch

## New in git-machete 2.8.4

- fixed: handle some extra cases happening when a tag named exactly as one of the managed branches exists in the repository
Expand All @@ -10,11 +14,11 @@

## New in git-machete 2.8.2

- fixed: handle the cases when a tag named exactly as one of the managed branches exists in the repository
- fixed: handle the cases when a tag named exactly as one of the managed branches exists in the repository

## New in git-machete 2.8.1

- fixed: handle the case when tracking information isn't set for a branch but the newly-chosen remote counterpart already exists (and thus a push with force or a pull might be needed)
- fixed: handle the case when tracking information isn't set for a branch but the newly-chosen remote counterpart already exists (and thus a push with force or a pull might be needed)

## New in git-machete 2.8.0

Expand Down Expand Up @@ -151,7 +155,7 @@

## New in git-machete 1.3.1

- added: extra checks for indent errors in the definition file
- added: extra checks for indent errors in the definition file

## New in git-machete 1.3.0

Expand Down
27 changes: 14 additions & 13 deletions git-machete
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import subprocess
import sys
import textwrap

VERSION = '2.8.4'
VERSION = '2.8.5'


# Core utils
Expand Down Expand Up @@ -553,19 +553,20 @@ def reflog(b):
return [entry.split(":", 1) for entry in non_empty_lines(popen_git("reflog", "show", "--format=%H:%gs", b, "--"))]


def is_relevant_reflog_subject(gs, b):
result = not (
gs.startswith("branch: Created from") or
gs.startswith("branch: Reset to " + b) or
gs.startswith("branch: Reset to HEAD") or
gs.startswith("reset: moving to ")
)
debug("is_relevant_reflog_subject(<<%s>>, %s)" % (gs, b), "result: %s" % result)
return result


def adjusted_reflog(b, prefix):
result = [sha for (sha, gs) in reflog(prefix + "/" + b) if is_relevant_reflog_subject(gs, b)]
def is_relevant_reflog_subject(sha, gs):
result = not (
gs.startswith("branch: Created from") or
gs == "branch: Reset to " + b or
gs == "branch: Reset to HEAD" or
gs.startswith("reset: moving to ") or
gs == "rebase finished: %s/%s onto %s" % (prefix, b, sha)
)
if not result:
debug("adjusted_reflog(%s, %s) -> is_relevant_reflog_subject(%s, <<<%s>>>)" % (b, prefix, sha, gs), "skipping reflog entry")
return result

result = [sha for (sha, gs) in reflog(prefix + "/" + b) if is_relevant_reflog_subject(sha, gs)]
debug("adjusted_reflog(%s, %s)" % (b, prefix), "computed adjusted reflog (= reflog without branch creation and branch reset events irrelevant for fork point/upstream inference): %s\n" %
(", ".join(result) or "<empty>"))
return result
Expand Down

0 comments on commit d87187c

Please sign in to comment.