Re: [PATCH v2 3/6] tests: use `git submodule add` and fix expected diffs
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 6, 2023, 23:57 UTC
- Message-ID
- <xmqqlek977se.fsf@gitster.g>
- In-Reply-To
- <kl6lsfehihdv.fsf@chooglen-macbookpro.roam.corp.google.com>
Glen Choo <chooglen@google.com> writes:
Show 10 quoted lines
> E.g. we could have ignored .gitmodules during the diff like so > > test_expect_success 'added submodule' ' > git submodule add ./sm1 && > gitmodules_hash1=$(git rev-parse --short $(git hash-object .gitmodules)) && > - git diff-index -p --submodule=log HEAD >actual && > + git diff-index -p --submodule=log HEAD -- :!.gitmodules >actual && > > and then we wouldn't have to adjust the diff. That would be my preferred > approach, since it keeps the irrelevant details out of the test.
Yes, it certainly does make the diff simpler to read, but the reasoning cuts both ways.
The end-goal of the topic is to propose that updating .gitmodules is an integral part of "adding a submodule" and to make it impossible to just add gitlink without a command line option using "git add", so from that point of view, readers would expect that the diff after "adding a submodule" to have both new gitlink and also a modified (or if this were the first submodule, added) ".gitmodules" file.