threads / patch / 45717

patchsubmodule: remove a superfluous second check for the "new" variable

Subject: [PATCH] submodule: remove a superfluous second check for the "new" variable

## tl;dr

3 messages between Apr 17, 2017 and Apr 17, 2017. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

Sebastian Schuberth· Apr 17, 2017, 07:59 UTC · lore
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
---
 submodule.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
Show changes to submodule.c +1 −3
diff --git a/submodule.c b/submodule.c
index c52d663..68623bd 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1396,8 +1396,7 @@ int submodule_move_head(const char *path,
 			cp1.no_stdin = 1;
 			cp1.dir = path;
 
-			argv_array_pushl(&cp1.args, "update-ref", "HEAD",
-					 new ? new : EMPTY_TREE_SHA1_HEX, NULL);
+			argv_array_pushl(&cp1.args, "update-ref", "HEAD", new, NULL);
 
 			if (run_command(&cp1)) {
 				ret = -1;

--
https://github.com/git/git/pull/345
Stefan Beller· Apr 17, 2017, 18:02 UTC · re: Sebastian Schuberth · lore

Re: [PATCH] submodule: remove a superfluous second check for the "new" variable

On Mon, Apr 17, 2017 at 12:59 AM, Sebastian Schuberth <sschuberth@gmail.com> wrote:

Show 16 quoted lines
> Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
> ---
>  submodule.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/submodule.c b/submodule.c
> index c52d663..68623bd 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -1396,8 +1396,7 @@ int submodule_move_head(const char *path,
>                         cp1.no_stdin = 1;
>                         cp1.dir = path;
>
> -                       argv_array_pushl(&cp1.args, "update-ref", "HEAD",
> -                                        new ? new : EMPTY_TREE_SHA1_HEX, NULL);
> +                       argv_array_pushl(&cp1.args, "update-ref", "HEAD", new, NULL);
EMPTY_TREE_SHA1_HEX != NULL?
Can you clarify the intent in the commit message?

Thanks, Stefan

Sebastian Schuberth· Apr 17, 2017, 18:21 UTC · re: Stefan Beller · lore

Re: [PATCH] submodule: remove a superfluous second check for the "new" variable

On 2017-04-17 20:02, Stefan Beller wrote:
Show 15 quoted lines
>> diff --git a/submodule.c b/submodule.c
>> index c52d663..68623bd 100644
>> --- a/submodule.c
>> +++ b/submodule.c
>> @@ -1396,8 +1396,7 @@ int submodule_move_head(const char *path,
>>                          cp1.no_stdin = 1;
>>                          cp1.dir = path;
>>
>> -                       argv_array_pushl(&cp1.args, "update-ref", "HEAD",
>> -                                        new ? new : EMPTY_TREE_SHA1_HEX, NULL);
>> +                       argv_array_pushl(&cp1.args, "update-ref", "HEAD", new, NULL);
> 
> EMPTY_TREE_SHA1_HEX != NULL?
> 
> Can you clarify the intent in the commit message?
Sure. A few lines up (3 lines out of the diff) we have "if (new) {" [1], thus there's no need to check "new != NULL" here again.
[1] https://github.com/git/git/pull/345/files#diff-471db3ea6697763218bb8335a95ece57R1392
-- 
Sebastian Schuberth

← back to recent threads