Github questions

For the more technical/geeky chat subjects!

Moderator: satrow

User avatar
Fedor2
Astronaut
Astronaut
Posts: 542
Joined: Mon, 11 Apr 2016, 01:26

Github questions

Unread postby Fedor2 » Thu, 30 Mar 2017, 03:39

I want extract commits for one certain date, to apply them in the code, i read github help but not found a clue how to do this.
Is it possible?

adisib
Lunatic
Lunatic
Posts: 357
Joined: Sat, 13 Jun 2015, 03:34
Location: KY

Re: Github questions

Unread postby adisib » Thu, 30 Mar 2017, 04:31

I don't think it is possible from the Github UI. But you can do it on a local copy of the repository on your computer if you have git installed.

The first thing that would come to mind for me would be something like (use %ad instead of %cd if you want the author date instead of the commit date):

Code: Select all

git log --pretty=format:"%h - %cd" | grep "Mar 16 .* 2017"


Which would return something like:

Code: Select all

ac8e1ef - Thu Mar 16 19:27:33 2017 -0400
f998c78 - Thu Mar 16 19:24:50 2017 -0400
e8ec8a5 - Thu Mar 16 19:15:52 2017 -0400


This gives you the commits for that particular day (March 16 2017 in that example), if you have cloned the repository and run the commands for your local version. You would need grep for this. There's likely to be a much better way, but it isn't coming up off the top of my head.

-----

Edit:
Decided to look on man pages to see if there was an much easier way.

You could do something similar to the above in a much better way with this (note this is author date, not commit date) and you don't need to have grep:

Code: Select all

git log --since="2017-3-15" --until="2017-3-17" --oneline


This will output:

Code: Select all

ac8e1ef [Commit message]
f998c78 [Commit message]
e8ec8a5 [Commit message]

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 21942
Joined: Sun, 28 Aug 2011, 17:27
Location: 58.5°N 15.5°E
Contact:

Re: Github questions

Unread postby Moonchild » Thu, 30 Mar 2017, 08:45

Managing commits in GitHub is very limited. You should probably use a graphical git client like SourceTree for convenience when trying to cherry-pick commits.
Improving Mozilla code: You know you're on the right track with code changes when you spend the majority of your time deleting code.

"If you want to build a better world for yourself, you have to be willing to build one for everybody." -- Coyote Osborne

User avatar
Fedor2
Astronaut
Astronaut
Posts: 542
Joined: Mon, 11 Apr 2016, 01:26

Re: Github questions

Unread postby Fedor2 » Tue, 04 Apr 2017, 17:42

Still failed to do what i want

First i do

Code: Select all

..\bin\git log --since="2016-12-15" --until="2017-1-10" --patch > p111222

It produces a file, seems valid.
Then

Code: Select all

..\bin\git checkout 27.0_RelBranch

It also executes normally
And finally

Code: Select all

..\bin\git apply p111222

Has bunch of errors
error: patch failed: toolkit/jetpack/moz.build:163
error: toolkit/jetpack/moz.build: patch does not apply
error: patch failed: toolkit/jetpack/moz.build:161
error: toolkit/jetpack/moz.build: patch does not apply
error: dom/media/platforms/ffmpeg/FFmpegFunctionList.h: No such file or director
y
error: dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp: No such file or direc
tory
error: dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.h: No such file or directo
ry
error: dom/media/platforms/ffmpeg/FFmpegFunctionList.h: No such file or director
y
error: dom/media/platforms/ffmpeg/FFmpegLibs.h: No such file or directory
error: dom/media/platforms/ffmpeg/libav53/include/libavformat/avformat.h: No suc
h file or directory
error: dom/media/platforms/ffmpeg/libav53/include/libavformat/avio.h: No such fi
le or directory
error: dom/media/platforms/ffmpeg/libav53/include/libavformat/version.h: No such
file or directory
error: dom/media/platforms/ffmpeg/libav54/include/libavformat/avformat.h: No suc
h file or directory
error: dom/media/platforms/ffmpeg/libav54/include/libavformat/avio.h: No such fi
le or directory
error: dom/media/platforms/ffmpeg/libav54/include/libavformat/version.h: No such
file or directory
error: dom/media/platforms/ffmpeg/libav55/include/libavformat/avformat.h: No suc
h file or directory
error: dom/media/platforms/ffmpeg/libav55/include/libavformat/avio.h: No such fi
le or directory
error: dom/media/platforms/ffmpeg/libav55/include/libavformat/version.h: No such
file or directory
error: dom/media/platforms/ffmpeg/FFmpegAudioDecoder.cpp: No such file or direct


What i do wrong?

adisib
Lunatic
Lunatic
Posts: 357
Joined: Sat, 13 Jun 2015, 03:34
Location: KY

Re: Github questions

Unread postby adisib » Tue, 04 Apr 2017, 18:59

Try using format-patch:

Code: Select all

git format-patch C1..C2
git checkout 27.0_RelBranch
git am *.patch

where C1 is the first commit hash that you want to add, and C2 is the last.

User avatar
New Tobin Paradigm
Knows the dark side
Knows the dark side
Posts: 4584
Joined: Tue, 09 Oct 2012, 19:37

Re: Github questions

Unread postby New Tobin Paradigm » Tue, 04 Apr 2017, 18:59

See: viewtopic.php?f=29&t=15014&p=108551#p108551

This explains the basic overview of Pale Moon development.. You should be able to gleam your answer from it. If not.. Someone else can explain.

User avatar
Fedor2
Astronaut
Astronaut
Posts: 542
Joined: Mon, 11 Apr 2016, 01:26

Re: Github questions

Unread postby Fedor2 » Tue, 11 Apr 2017, 06:08

adisib
No way, if c1 c2 commit numbers like c93fb24 , format-patch produses a bunch of files but no c93fb24, git am is something to do with mail and errors about *.patch. Tried different format-patch options, stood for nothing the git manual.
Oh dear how it so obscure. why???

So how to do if only one commit c93fb24?

_ntnn
Newbie
Newbie
Posts: 6
Joined: Fri, 08 Jan 2016, 20:15
Location: noop

Re: Github questions

Unread postby _ntnn » Tue, 11 Apr 2017, 11:46

Fedor2 wrote:adisib
No way, if c1 c2 commit numbers like c93fb24 , format-patch produses a bunch of files but no c93fb24


Yes, that is what format-patch is designed to do.

git am is something to do with mail and errors about *.patch.

git-am is used to apply patches attached to email, e.g. via git-send-email, to the local code base - not patch files.

To apply diffs (as generated by format-patch) to your local code base you'll have to use git-apply.

What adisib was explaining was that you could go two ways.
a) Generate patch files and apply them to your local tree (git-format-patch then git-apply)
b) Output the sha-sums with git-log and then git-cherry-pick them in your local tree.

User avatar
Fedor2
Astronaut
Astronaut
Posts: 542
Joined: Mon, 11 Apr 2016, 01:26

Re: Github questions

Unread postby Fedor2 » Wed, 19 Apr 2017, 17:51

At last I can make git do desired patches.
But i stay very confused anyway. Like all commits are applied according to its list, but it seems is not, where to get its right sequence?

Example
https://github.com/MoonchildProductions ... f61ce3cadd
is located before the
https://github.com/MoonchildProductions ... 01400dc154
which is already applied inside 27.0_Relbranch. And it will errors about it.

User avatar
filip
Hobby Astronomer
Hobby Astronomer
Posts: 15
Joined: Wed, 08 Feb 2017, 15:52
Location: Serbia

Re: Github questions

Unread postby filip » Wed, 19 Apr 2017, 19:34

@Fedor2:

As Moonchild said, "git cherry-pick" is your best friend here.
Since you haven't provided any details it's hard to be specific, so please tell us which commits, from which branch and where to are you trying to apply them ( onto which branch )!?

For the sake of example, I'll assume here that you want to apply some commit range onto master. If so:

1. First make sure that you localy have the branch you're picking from:

Code: Select all

git pull origin branch_name

2. Then make sure you're on the master (target) branch:

Code: Select all

git checkout master

3. Now cherry-pick:

Code: Select all

git cherry-pick C1..C2


:)

User avatar
Fedor2
Astronaut
Astronaut
Posts: 542
Joined: Mon, 11 Apr 2016, 01:26

Re: Github questions

Unread postby Fedor2 » Thu, 20 Apr 2017, 02:19

I'm trying to apply commits after the 27.0_relbranch and before 27.1 on the 27.0_relbranch

I did as [/b]filip[b] suggest, but without pull, i have already all branch, so i decided not do it.

Code: Select all

git checkout 27.0_relbranch
git cherry-pick 27.0_relbranch..8b3e92a

Got

Code: Select all

error: could not apply 79c8db4... Replace dom::TimeRanges with TimeIntervals object
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'


This is even more confusing.


With format-patch method even if i can see which patch failed.

User avatar
New Tobin Paradigm
Knows the dark side
Knows the dark side
Posts: 4584
Joined: Tue, 09 Oct 2012, 19:37

Re: Github questions

Unread postby New Tobin Paradigm » Thu, 20 Apr 2017, 04:39

Use a GUI for gods sake and cherry pick only the commit you want.. Also, why do you need to cherry pick at all to an old relbranch.. That isn't how the branch structure is.. structured..

User avatar
Fedor2
Astronaut
Astronaut
Posts: 542
Joined: Mon, 11 Apr 2016, 01:26

Re: Github questions

Unread postby Fedor2 » Thu, 20 Apr 2017, 06:04

The matter is not about chery-pick exactly, i was searching any means to make span between 27.0 and 27.1. Because something there breaks one particular site. I think about to apply commits sequentially beginning from 27.0_RelBranch.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 21942
Joined: Sun, 28 Aug 2011, 17:27
Location: 58.5°N 15.5°E
Contact:

Re: Github questions

Unread postby Moonchild » Thu, 20 Apr 2017, 06:21

Why don't you just "checkout" the individual commits on the master branch that you want to look at?
that way you don't have to manually apply/pick anything, and you can bisect to quickly home in on the issue.
Improving Mozilla code: You know you're on the right track with code changes when you spend the majority of your time deleting code.

"If you want to build a better world for yourself, you have to be willing to build one for everybody." -- Coyote Osborne

User avatar
Fedor2
Astronaut
Astronaut
Posts: 542
Joined: Mon, 11 Apr 2016, 01:26

Re: Github questions

Unread postby Fedor2 » Thu, 20 Apr 2017, 07:21

Oh thanks!
This is good idea, but...

Code: Select all

error: The following untracked working tree files would be overwritten by checkout:
        dom/media/platforms/ffmpeg/libav53/include/libavformat/avformat.h
        dom/media/platforms/ffmpeg/libav53/include/libavformat/avio.h
        dom/media/platforms/ffmpeg/libav53/include/libavformat/version.h
        dom/media/platforms/ffmpeg/libav54/include/libavformat/avformat.h
        dom/media/platforms/ffmpeg/libav54/include/libavformat/avio.h
        dom/media/platforms/ffmpeg/libav54/include/libavformat/version.h
        dom/media/platforms/ffmpeg/libav55/include/libavformat/avformat.h
        dom/media/platforms/ffmpeg/libav55/include/libavformat/avio.h
        dom/media/platforms/ffmpeg/libav55/include/libavformat/version.h
Please move or remove them before you can switch branches.
Aborting

Am i wrong, if i delete them? I already have deleted and checkout passed fine, but i worry.

User avatar
New Tobin Paradigm
Knows the dark side
Knows the dark side
Posts: 4584
Joined: Tue, 09 Oct 2012, 19:37

Re: Github questions

Unread postby New Tobin Paradigm » Thu, 20 Apr 2017, 07:29

If you are in doubt.. Delete the repository completely and re-clone.

User avatar
Fedor2
Astronaut
Astronaut
Posts: 542
Joined: Mon, 11 Apr 2016, 01:26

Re: Github questions

Unread postby Fedor2 » Mon, 26 Jun 2017, 12:55

Another question.

What is the good way to update source code?
1. Download from the github and replace old code
2. Execute git fetch inside existing old code folder
3. Execute git pull inside existing old code folder
4. Delete older folder and execute git clone

User avatar
JustOff
Localization Coordinator
Localization Coordinator
Posts: 1492
Joined: Thu, 03 Sep 2015, 19:47
Location: UA
Contact:

Re: Github questions

Unread postby JustOff » Mon, 26 Jun 2017, 13:06

Fetch does not update the code, you need to use pull. But as Tobin has already recommended above you better use GUI. My preferred is SourceTree.
Here are the add-ons I made in a spare time. That was fun!

User avatar
Fedor2
Astronaut
Astronaut
Posts: 542
Joined: Mon, 11 Apr 2016, 01:26

Re: Github questions

Unread postby Fedor2 » Mon, 26 Jun 2017, 13:53

So git pull is right, shall do it then. And about gui you suggested - too bad, it wont start in winxp.
I do use git on occasion, gui likely not needed.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 21942
Joined: Sun, 28 Aug 2011, 17:27
Location: 58.5°N 15.5°E
Contact:

Re: Github questions

Unread postby Moonchild » Mon, 26 Jun 2017, 14:15

I wouldn't recommend using Win XP as a development environment for anything the size of our code base. Besides, how do you think you are going to compile anything?
There are, by the way, several different GUIs for git available, all of them tons better than trying to do it from the command-line.
Improving Mozilla code: You know you're on the right track with code changes when you spend the majority of your time deleting code.

"If you want to build a better world for yourself, you have to be willing to build one for everybody." -- Coyote Osborne


Return to “Technical chat”

Who is online

Users browsing this forum: No registered users and 4 guests