1

I am trying to capture the output of this git command (or any for that matter).

git diff-tree --no-commit-id --patch-with-raw -r HEAD  # HEAD or some commit SHA

However, unlike an echo, the following command does not log any output in the GitHub actions log. Nor does it streams the output to a variable. On my local, the same command logs the changes made in the last commit.

# result is empty
result=$(git diff-tree --no-commit-id --patch-with-raw -r HEAD)

What am I missing? How do I capture the output of the above git command?

2 Answers 2

3

Are you using the checkout action to checkout your code? git diff-tree probably doesn't output anything if you're not fetching the history. Try

- uses: actions/checkout@v2
  with:
    fetch-depth: 0
Sign up to request clarification or add additional context in comments.

2 Comments

I was fooled by default fetch-depth: 1 to bear the latest commit. Changed to 5 for now and it works. Happy tears. Thanks so much.
Glad to hear it worked!
1

Probably something alike this... in every case with echo:

echo $(git diff-tree --no-commit-id --patch-with-raw -r HEAD)

1 Comment

No luck: imgur.com/a/gJQzUkD You can see that git status command logs output but the other git diff-tree ... does not. FYI, on my local, the same command logs the changes made in the last commit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.