Re: [PATCH v4] submodule: port subcommand 'set-url' from shell to C
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 7, 2020, 05:08 UTC
- Message-ID
- <xmqqv9l849i4.fsf@gitster.c.googlers.com>
- In-Reply-To
- <20200507044028.GA5168@konoha>
Shourya Shukla <shouryashukla.oo@gmail.com> writes:
> No worries. BTW, should I include the `path == NULL` check in the > if-statement?
If I were writing this code, I would probably write it like so:
if (!path || !newurl) oops;
Specifically, I would write "!path", not "path == NULL". I thought a rule for that is in the CodingGuidelines (I didn't double check, though).
The comparison on argc is to see if we are even allowed to access argv[0] and/or argv[1]. In practice, if what main() got from the outside world in argv[] is passed directly to you, argv[n] would never be NULL as long as n < argc, but there are a few levels of callchain between main() and you (i.e. module_set_url()), so not counting on that would be sensible.