From 465c9911c8d95cd7749618b8a6d4f4e6b7f7d173 Mon Sep 17 00:00:00 2001 From: "Christian P. V. Christoffersen" <88783438+br-cpvc@users.noreply.github.com> Date: Thu, 16 Jun 2022 15:38:18 +0200 Subject: [PATCH] added git_find_exact_file_based_on_hashsum.sh --- git_find_exact_file_based_on_hashsum.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 git_find_exact_file_based_on_hashsum.sh diff --git a/git_find_exact_file_based_on_hashsum.sh b/git_find_exact_file_based_on_hashsum.sh new file mode 100755 index 0000000..004bdeb --- /dev/null +++ b/git_find_exact_file_based_on_hashsum.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# from: https://www.endpoint.com/blog/2014/11/10/finding-specific-git-commit-at-point-in + +FILE=$1 +HASH=`git hash-object $FILE` +echo "Looking for hash $HASH, of file $FILE" +git rev-list --all \ + | while read commit + do if git ls-tree -r $commit \ + | grep -F -q $HASH + then echo "found in git commit $commit" + break + fi + done