0

I have read that the following command allows you to see all changed files of the last commit:

git diff-tree --no-commit-id --diff-filter=d --name-only -r $(Build.SourceVersion)

Unfortunately I have no luck, the command does not show anything. How is that possible? I am currently on a branch called swagger-fix, so maybe the command is not able to see the branch? Thank you for your help.

Edoardo
  • 13
  • 5
  • Or maybe the commit contains only deletions? Your command explicitly excludes these (`--diff-filter=d`). – Romain Valeri Nov 21 '22 at 11:29
  • Hello Romain, the command does not contain any deletions, just changed files. What are the other reasons why the output may be empty? – Edoardo Nov 21 '22 at 11:48
  • 1
    What's the output of `$(Build.SourceVersion)`? Also why using `diff-tree` rather than `diff` here? – Romain Valeri Nov 21 '22 at 12:06
  • The output of $(Build.SourceVersion) is simply the commit hash code (I also tried hardcoding it and the result is the same). I already tried diff as well, but i get the same results: no output. – Edoardo Nov 22 '22 at 05:36
  • [Carnac the Magnificent](https://en.wikipedia.org/wiki/Carnac_the_Magnificent) says: You're using a CI system and you've forgotten to turn off shallow clones in the CI system. Turn off shallow clones (or set the depth to be at least 2). – torek Nov 22 '22 at 12:38
  • Thank you so much Carnac, you solved the issue! – Edoardo Nov 24 '22 at 08:58
  • @torek Haha, Carnac answers everything! :-D – Romain Valeri Nov 28 '22 at 11:24

1 Answers1

0

torek's comment is spot on:

Carnac the Magnificent says: You're using a CI system and you've forgotten to turn off shallow clones in the CI system. Turn off shallow clones (or set the depth to be at least 2).

So make sure to include such crucial information in your future questions :)

The solution: unshallow your CI clone or turn of shallow clones altogether.

knittl
  • 246,190
  • 53
  • 318
  • 364